﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace InterpolatorDotNET
{
    internal static class InterpolaterTools
    {
        //private static string[] listkeywords = {"System.Collections.Generic.List"};

        internal static Type[] extendedPrimativeTypes = 
            { 
                typeof(Decimal), 
                typeof(DateTime), 
                typeof(String),
                typeof(Guid),
                typeof(float),
                typeof(bool),
                typeof(Boolean)
            };
        private static bool primativeExtTest(Type t)
        {
            return extendedPrimativeTypes.Contains(t);
        }
        internal static bool IsEnumerable(object o)
        {
            PropertyInfo countprop = o.GetType().GetProperty("Count");
            if (countprop != null)
                return true;

            PropertyInfo lengthprop = o.GetType().GetProperty("Length");
            if (lengthprop != null)
                return true;

            return false;
        }
        internal static bool IsPrimative(object o)
        {
            return IsPrimative(o.GetType());
        }
        internal static bool IsEnum(object o)
        {
            return o.GetType().IsEnum;
        }
        internal static bool IsPrimative(Type t)
        {
            if (t.IsPrimitive || primativeExtTest(t))
                return true;
            return false;
        }



    }
}
